#ifndef __CHANNEL_HPP__
#define __CHANNEL_HPP__

#include<iostream>
#include<unistd.h>

class Channel{
public:
	Channel(int wfd,pid_t who):_wfd(wfd),_who(who){
		_name="Channel-"+std::to_string(_wfd)+"-"+std::to_string(_who);
	}
	~Channel(){}

	void Send(int cmd){
		::write(_wfd,&cmd,sizeof(cmd));
	} 
	void Close(){
		::close(_wfd);
	}

	int wFd(){
		return _wfd;
	}
	pid_t Id(){
		return _who;
	}
	std::string Name(){
		return _name;
	}

private:
	int _wfd;
	pid_t _who;
	std::string _name;
};
#endif